package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;
import com.yanqu.road.utils.string.StringUtils;

import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * 剩余手牌仅持有某种花色，可以触发效果
 * 花色|加筹码|乘筹码|加倍率|乘倍率|金币
 */
public class FoxCardEffect4 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        if (triggerType != eFoxCardTriggerType.AFTER_SCORE) {
            return;
        }

        if (gameLogic.getGameData().getHandCards().isEmpty()) {
            return;
        }

        Set<Integer> colors = StringUtils.stringToSet(effectConfig.getParamsList().get(0), ";");
        boolean isTrigger = true;
        for (FoxHandCard foxHandCard : gameLogic.getGameData().getHandCards()) {
//            if (foxHandCard.getColor() == -1) {//无花色,确认过需求石头牌也算花色
//                continue;
//            }
            if (gameLogic.getConfig().isAllColorHandCard(foxHandCard.getReinforceEffect())) {//万能色
                continue;
            }
            if (!colors.contains(foxHandCard.getColor())) {
                isTrigger = false;
                break;
            }
        }
        if (isTrigger) {
            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);
            gameLogic.addBaseScore(Integer.valueOf(effectConfig.getParamsList().get(1)), foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(Integer.valueOf(effectConfig.getParamsList().get(2)), foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(Integer.valueOf(effectConfig.getParamsList().get(3)), foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(Integer.valueOf(effectConfig.getParamsList().get(4)), foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(Integer.valueOf(effectConfig.getParamsList().get(5)), foxEffectCards, null, triggerType); //加金币
        }

    }
}
